home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 6_17.lha / 6_17 / 6_17a5.c < prev    next >
C/C++ Source or Header  |  1993-08-08  |  394b  |  23 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. / x = 5.0
  6. ector& vector::operator=(float x)
  7.  
  8.    int l = p->length;
  9.    if (p->refcnt > 1)
  10. {
  11. p->refcnt--;
  12. p = new vrep;
  13. p->length = l;
  14. p->refcnt = 1;
  15. p->f = new float[l];
  16. }
  17.  
  18.    float *f = p->f;
  19.    for (int i = 0; i < l; i++)
  20. *f++ = x;
  21.    return *this;
  22.  
  23.